package global

import (
	"simple-app/structs/tables"
	"sync"
)

var (
	Buying        bool           // 抢购开始开关
	SettingConfig tables.Setting // 全局配置参数
	sysMutex      sync.Mutex
)

// StartBuying 系统进入抢购时机
func StartBuying() {
	sysMutex.Lock()
	defer sysMutex.Unlock()
	Buying = true
}

// EndBuying 系统结束抢购时机
func EndBuying() {
	sysMutex.Lock()
	defer sysMutex.Unlock()
	Buying = false
}

// UpdateSettingCatch 更新全局设置缓存
func UpdateSettingCatch(m tables.Setting) {
	sysMutex.Lock()
	defer sysMutex.Unlock()
	SettingConfig = m
}
